package com.wzq.util;


import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;

/**  
 * json自定义mapper，过滤掉null值   
 * @ClassName: JsonMapper    
 * @author 陈剑飞    
 * @date 2016年6月1日 下午3:47:56    
 * @version  v 1.0    
 */
public class JsonCustomerMapper extends ObjectMapper{
    private static final long serialVersionUID = 1L;
    public JsonCustomerMapper(){
        this.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
        this.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
        this.setSerializationInclusion(Include.NON_NULL);
        this.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);    //不输出value=null的属性
        this.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); //不知道的属性，不异常
    }
}
